package com.example.demo.bean;

import com.example.demo.dao.UserInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class BeanTest {
    @Bean
    public String name(){
        return "zhangsan";
    }
    @Bean
    public String name2(){
        return "lisi";
    }
//    @Primary //指定该bean为默认bean的实现
    @Bean("u1")
    public UserInfo user1(String name){
        UserInfo userInfo = new UserInfo();
        userInfo.setName(name);
        userInfo.setAge(12);
        return userInfo;
    }
    @Bean
    public UserInfo user2(){
        UserInfo userInfo = new UserInfo();
        userInfo.setName("liudong");
        userInfo.setAge(19);
        return userInfo;
    }
}
